extends Label

func _ready():
	$"..".score_updated.connect(update_score)  # 新语法

func update_score(new_score):
	text = "SCORE: %d" % new_score
	if new_score > 50000:
		$"../Spawner/TimerBoss".stop()
		$"../Spawner/Timer".stop()
		await get_tree().create_timer(10).timeout
		$"../win".visible = true
		# 检查场景树有效性后延迟调用
		await get_tree().create_timer(5).timeout
		if is_instance_valid(get_tree()):
			get_tree().call_deferred("reload_current_scene")
		else:
			push_error("场景树已释放！")
